package com.datoucai.consumer;

import com.datoucai.dto.NotificationVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;

@Service
public class PushNotificationService {
    // 通过SimpMessagingTemplate推送消息
    @Autowired
    private SimpMessagingTemplate messagingTemplate;

    public void pushNotification(Long userId, NotificationVO notification) {
        // 推送到用户专属频道（如：/topic/user/123）
        messagingTemplate.convertAndSend("/topic/user/" + userId, notification);
    }
}